package com.changanw.business.service;

import com.changanw.business.feign.OrderFeign;
import com.changanw.business.feign.StorageFeign;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**

 */
@Service
public class BusinessService {
    @Autowired
    StorageFeign storageFeign;
    @Autowired
    OrderFeign orderFeign;

    @GlobalTransactional //分布式事务注解
    public void purchase(String account, String productId, Integer count) {
        //调用订单微服务
        orderFeign.createOrder(account, productId, count);
        //调用库存服务
        storageFeign.deduct(productId, count);
    }
}